//
//  YWTabBarViewController.m
//  maintain
//
//  Created by 郑想 on 15/10/9.
//  Copyright (c) 2015年 ewin. All rights reserved.
//

#import "MJExtension.h"
#import "QRCodeReaderViewController.h"
#import "UIColor+CustomColors.h"
#import "YWMacro.h"
#import "YWConst.h"

#import "YWNavigationController.h"
#import "YWProfileViewController.h"

#import "YWTabBar.h"
#import "YWTabBarViewController.h"
#import "YWCommonTool.h"
#import "YWLoginTool.h"
#import "YWQrcodeManager.h"

@interface YWTabBarViewController () <YWTabBarDelegate>
@end

@implementation YWTabBarViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self initSubController];

    YWTabBar* tabBar = [[YWTabBar alloc] init];
    [self setValue:tabBar forKeyPath:@"tabBar"];
    
//    NSString *noReadCount = [NSString stringWithFormat:@"%ld",(long)[YWLoginTool noticeAndTempMissionTotalNoRedCount]];
//    if ([noReadCount integerValue]>0) {
//        self.childViewControllers[1].tabBarItem.badgeValue = noReadCount;
//    }else{
//        self.childViewControllers[1].tabBarItem.badgeValue = nil;
//    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)initSubController
{
//    YWWorkViewController* look = [[YWWorkViewController alloc] init];
//    [self addChildVC:look title:@"工作" image:@"tabbar_work" selectedImage:@"tabbar_work_selected"];

    YWProfileViewController* profile = [[YWProfileViewController alloc] init];
    [self addChildVC:profile title:@"发现" image:@"tabbar_profile" selectedImage:@"tabbar_profile_selected"];
}

- (void)addChildVC:(UIViewController*)childVc title:(NSString*)title image:(NSString*)image selectedImage:(NSString*)selectedImage
{
    childVc.title = title;

    childVc.tabBarItem.image = [UIImage imageNamed:image];
    childVc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    YWNavigationController* nav = [[YWNavigationController alloc] initWithRootViewController:childVc];
    [self addChildViewController:nav];
}

#pragma mark - YWTabBarDelegate代理方法
- (void)tabBarDidClickScanButton:(YWTabBar*)tabBar
{
    //delegate
}

@end
